<?php
namespace app\Logic\Layui\Service;

use app\Logic\Layui\ServiceProviders\Loger;
use app\Logic\Logic;
use Illuminate\Support\Facades\DB;

class ActionLog extends Logic implements ServiceInterface
{
    public $app;

    public function __construct(Loger $app)
    {
        $this->app = $app;
    }

    public function write(int $uid)
    {
        $uri = \Request::getRequestUri();
        $res = DB::table('auth')->where(['auth' => $uri])->first();

        if(!isset($res)){

            throw new \Exception('当前路由未添加到权限,请联系网站管理员');
        }

        DB::table('action_log')->insert([
            'uid' => $uid,
            'auth_id' => $res->id,
            'created_at' => date('Y-m-d H:i:s'),
            'updated_at' => date('Y-m-d H:i:s'),
        ]);
    }
}